package com.xizi.rabbit.service;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//rabbitmq服务 发送短信
@Service
public class RabbitService {

    //注入 RabbitTemplate
    @Autowired
    RabbitTemplate rabbitTemplate;

    /**
     * 发送信息
     * @param exchange 交换机
     * @param routingKey 路由key
     * @param message 消息
     * @return
     */
    public boolean sendMessage(String exchange,String routingKey,Object message){
        //rabbitTemple调用转换并且发送
        rabbitTemplate.convertAndSend(exchange,routingKey,message);
        return true;
    }
}
